﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using CoreInmobiliario.Data;

namespace CoreInmobiliario.Business
{
    [DataObject]
    public class Moneda
    {
        public static Moneda GetInstance()
        {
            return new Moneda();
        }

        private static DBDataContext GetDBDataContext()
        {
            Factories.DBDataContextFactory factory = new Factories.DBDataContextFactory();
            return factory.CreateDataContext() as DBDataContext;
        }

        public Data.Moneda GetById(int monedaId)
        {
            Data.Moneda moneda = null;

            using (DBDataContext dataContext = GetDBDataContext())
            {
                try
                {
                    moneda = dataContext.Monedas.FirstOrDefault(m => m.MonedaId.Equals(monedaId));
                }
                catch (Exception ex)
                {

                }
            }
            return moneda;
        }

        public List<Data.Moneda> GetList()
        {
            List<Data.Moneda> list = null;

            using (DBDataContext dataContext = GetDBDataContext())
            {
                try
                {
                    list = dataContext.Monedas.ToList();

                }
                catch (Exception ex)
                {

                }
            }
            return list;
        }
    }
}
